package com.tidc.dashboard;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
@EnableHystrixDashboard
@SpringBootApplication
public class DashboardApplication {

	public static void main(String[] args) {
		SpringApplication.run(DashboardApplication.class, args);
	}
	@Bean
	public ServletRegistrationBean  getServlet() {

		HystrixMetricsStreamServlet streamServlet =new HystrixMetricsStreamServlet();

		ServletRegistrationBean registrationBean =new ServletRegistrationBean(streamServlet);

		registrationBean.setLoadOnStartup(1);

		registrationBean.addUrlMappings("/hystrix.stream");

		registrationBean.setName("HystrixMetricsStreamServlet");

		return registrationBean;

	}

}
